//require(["config"],function(config){
//	require(["jquery","cookie"],function(jq,cookie){
//		
$(function(){
		//热销爆品
		$.getJSON("js/details.json",function(s){
			var img = s.deta.img;
			var font = s.deta.font;
			var pic = s.deta.pic;
			var ul = $(".count4_div ul");
			$.each(img, function(j) {
//				<a href="#"><img src="scss/img/xiangqing/01_200x200.jpg"/></a>
//				<p class="slide-prd-name">MAYBELLINE美宝莲眼部及唇部卸妆液70ml</p>
//				<span class="price-hd">￥<i>21.9</i></span>
				$("<li><a href='#'><img src='" + img[j] + "'/></a><p class='slide-prd-name'><a href='#'>" + font[j] +
				"</a></p><span class='price-hd'>￥<i>" + pic[j] + "</i></span></li>").appendTo(ul);
			});
					
	 		//首先获取ul的总宽度
			$('.count4_div ul').css("width",$(".count4_div ul li").outerWidth()*$(".count4_div ul li").length);			
			var cont4_index = 0;
			$("#btn_right_a").on("click",function(){
				if(-$('.count4_div ul').position().left<$(".count4_div").outerWidth()-$(".count4_div ul li").outerWidth()*($(".cont4_div ul li").length/2)){
					cont4_index++;
					if(cont4_index>$(".count4_div ul li").length/2){
						cont3_index=$(".count4_div ul li").length/2;
						return;
					}
					$(".count4_div ul").stop().animate({left:(-$(".count4_div ul li").outerWidth()*cont4_index*5)+"px"})
				}
			});			
			$("#btn_left_a").on("click",function(){
				if($(".count4_div ul").position().left<0){
					cont4_index--;
					if(cont4_index<0){
						cont4_index=0;
						return;
					}
					
					$(".count4_div ul").stop().animate({left:(-$(".count4_div ul li").outerWidth()*cont4_index*5)+"px"})				
				}
			});
		});
	})	
		//二级菜单
		$(function(){
			$(".nav_menu a").mouseenter(function(){
			
				var index = $(this).index();
				$(".nav_menu .headlist").eq(index).css("display","block" 	)				             
			})				
			$(".nav_menu").mouseleave(function(){
				$(".nav_menu .headlist").css("display","none");
				
			})
		});
				
		$(function(){
			//放大镜
			$(" #imagelist li").mouseover(function(){
				$(this).css("border","1px solid #ccc").siblings().css("border","none");
				
				$(".big-img-box li").find("img").attr("src",$(this).find("img").attr("src"))
				$(".main-img-box .big_pic").find("img").attr("src",$(this).find("img").attr("src"))				
			});
			$(".big-img-box").mouseenter(function(){
				$("#zhezhao").css("display","block")
				$(".big_pic").css("display","block")
				$(document).mousemove(function(e){
									
				var _left = e.clientX-$(".big-img-box").offset().left-$("#zhezhao").width()/2+$(document.body).scrollLeft();
				var _top = e.clientY-$(".big-img-box").offset().top-$("#zhezhao").height()/2+$(document.body).scrollTop();	
				_left = Math.min(Math.max(0,_left),$(".big-img-box").width()-$("#zhezhao").width());
				_top = Math.min(Math.max(0,_top),$(".big-img-box").height()-$("#zhezhao").height());
				
				$("#zhezhao").css({"left":_left,"top":_top});
					if(_left < 0){
						_left = 0;
					}
					if(_left>Math.min(Math.max(0,_left),$(".big-img-box").width()-$("#zhezhao").width())){
						_left=Math.min(Math.max(0,_left),$(".big-img-box").width()-$("#zhezhao").width())
						
					}
					if(_top<0){
						_top=0;	
					}	
					if(_top>Math.min(Math.max(0,_top),$(".big-img-box").height()-$("#zhezhao").height())){
						_top=Math.min(Math.max(0,_top),$(".big-img-box").height()-$("#zhezhao").height())	
					}	
					var scale=$("#big").width()/$("#smal").width();
					Bleft=-_left*scale;
					Btop=-_top*scale;
					$("#big").css({"left":Bleft,"top":Btop})
					
				});	
		
			});
			
			
			$(".big-img-box").mouseleave(function(){
				$("#zhezhao").css("display","none")
				$(".big_pic").css("display","none")
			})
			
			//商品详情tab切换
			$(".tab1").click(function(){
				var $index = $(this).index(); //找到了对应的序列号
				var $top = $(".detail-con-tit").eq($index).offset().top; //获取制定Louti与浏览器上面的距离
				//	console.log( $top );
				$("body,html").animate({
					scrollTop: $top
				}, 500, function() {
					mark = 1;
				}); //浏览器滚动的高度
			});
		});	
		//数量加减
		//jia
	$(function(){
		$(".more").click(function(){
			var value=parseInt($("#buycount").val())+1;
       		$("#buycount").val(value);
		})
		//jian
		$(".less").click(function(){	
			var num = $("#buycount").val()
			if(num>1){
				$("#buycount").val(num-1);
			}			
			
		})
		$(".buy-cart").click(function(){
			var l = $("#buycount").val();
			$("l").html()
		});
		//用户评论tab切换		
		var pj_type=document.getElementsByClassName("pj_type")[0];
		var jindas=pj_type.getElementsByClassName("tab3");
		var pings=document.getElementsByClassName("pl_type");
		for(var i=0;i<jindas.length;i++){
			jindas[i].index=i;			
			jindas[i].onclick=function(){
				for(var k=0;k<pings.length;k++){
					pings[k].index=k;
					if(this.index==pings[k].index){
						pings[k].style.display="block";									
					}else{
						pings[k].style.display="none"
					}
				}
			}
		}
	})	
		//顶部悬浮				
		$(function(){
			var dtop=$(".detail_r_tab .clear").offset().top;
			$(document).scroll(function(){
				var sh=$(document).scrollTop()-100;
				if(sh>dtop){
					$(".detail_r_tab .clear").css({"border-bottom":"2px solid #000","width":"100%","background":"#fff","z-index":"99"});
					$(".detail_r_tab .clear").css("position","fixed");
					$(".detail_r_tab .detail_r_pri").css("display","block");
					$(".detail_r_tab .clear").css("top",0);
					$(".detail_r_tab .clear").show()
				}
				if(sh<=dtop){
					$(".detail_r_tab .clear").css("border-bottom","2px solid #000")
					$(".detail_r_tab .clear").css("position","")
				}				
			});	
		});	
	$(function(){
		//返回顶部
		$("#gotop").click(function() {
			$("html,body").animate({
				scrollTop: 0
			}, 0);
		});
		$(".mpbtn_cart").click(function() {
			$(".gouwu").toggle();
		});
	});
//});
